Skip to content

Allowing on RedirectURIs the usage of regexp due to issue #448. - #4930

Open
SGT911 wants to merge 3 commits into
dexidp:masterfrom
SGT911:master
Open

Allowing on RedirectURIs the usage of regexp due to issue #448.#4930
SGT911 wants to merge 3 commits into
dexidp:masterfrom
SGT911:master

Conversation

@SGT911

@SGT911 SGT911 commented Jul 26, 2026

Copy link
Copy Markdown

Adding new flags for conditional logic and allowing back compatibility of the feature

Overview

Adds support for regexp-based redirect URI matching in static clients, controlled by two new flags. This addresses issue #448 and maintains full backward compatibility.

What this PR does / why we need it

New fields on storage.Client:
  • InsecureAllowRegexpRedirectURIs — enables treating RedirectURIs entries as regexp patterns (matched against the actual redirect URI at auth time).
  • InsecureAllowWildcardRedirectURIs — additionally permits wildcard patterns containing .* (e.g. https?://.*). This is a separate flag because wildcards are significantly more permissive and intended mainly for development.
Behavior:
  • When neither flag is set (default), redirect URIs are matched literally — no change from current behavior.
  • When InsecureAllowRegexpRedirectURIs=true, each RedirectURIs entry is compiled as a Go regexp and matched against the requested redirect URI. Entries containing .* are rejected unless InsecureAllowWildcardRedirectURIs=true.
  • Validation of the regexp expressions happens at serve time (cmd/dex/serve.go) so misconfigurations fail fast on startup.

Special notes for your reviewer

The regexp matching is opt-in per client via explicit flags. The double-flag design (InsecureAllowRegexpRedirectURIs + InsecureAllowWildcardRedirectURIs) adds a deliberate friction layer so wildcards can't be used accidentally. Regexp compilation errors are caught at startup, not at auth time.

…p#448.

Adding new flags for conditional logic and allowing back compatibility of the feature

Signed-off-by: Sebastian Gaviria Tangarife <sgt.911@outlook.com>
@SGT911 SGT911 reopened this Jul 26, 2026
SGT911 added 2 commits July 25, 2026 20:06
…atch abuse

Signed-off-by: Sebastian Gaviria Tangarife <sgt.911@outlook.com>
Signed-off-by: Sebastian Gaviria Tangarife <sgt.911@outlook.com>
@SGT911 SGT911 changed the title Draft PR: Allowing on RedirectURIs the usage of regexp due to issue #448. Allowing on RedirectURIs the usage of regexp due to issue #448. Jul 26, 2026
@sergiofteixeira

Copy link
Copy Markdown

hey @sagikazarmark who can review such changes?

@sagikazarmark

Copy link
Copy Markdown
Member

@sergiofteixeira thanks for the ping. Added to my list, but I'm not in front of a computer right now. Ping me next week please if I don't respond.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds opt-in regular-expression matching for static-client redirect URIs while retaining literal matching by default.

Changes:

  • Adds per-client regexp and wildcard flags.
  • Implements startup validation, runtime matching, and tests.
  • Qualifies Docker image references with registry names.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
storage/storage.go Defines the new client flags.
server/authflow/request.go Implements regexp redirect matching.
server/authflow/request_test.go Tests regexp and wildcard behavior.
cmd/dex/serve.go Validates configured expressions at startup.
Dockerfile Qualifies builder image references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/dex/serve.go
Comment on lines +248 to +249
if !client.InsecureAllowWildcardRedirectURIs && strings.Contains(uri, ".*") {
return fmt.Errorf("invalid config: InsecureAllowWildcardRedirectURIs is required when using \".*\"")
Comment thread storage/storage.go
Comment on lines +169 to +170
// InsecureAllowRegexpRedirectURIs is an additiona flag allowing, add to
// RedirectURIs regexp expressions for dynamic URIs.
Comment on lines +159 to +170
func surroundRedirectURIRegexp(uri string) (result string) {
result = uri
if result[0] != '^' {
result = "^" + result
}

if result[len(result)-1] != '$' {
result = result + "$"
}

return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants